#@embedLayout()


#define content()

<ul id="tt"></ul>

<div id="resourceTreeMM" class="easyui-menu" style="width:120px;display: none;">
    <div onclick="selectedAllChildNode()">选中所有子节点</div>
    <div onclick="rmoveSelectedAllChildNode()">取消选中所有子节点</div>
</div>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    $(function () {
        $('#tt').tree({
            url: contextRootPath + "/resource/getTreeList/#(role_id)-1",
            animate: true,
            checkbox: true,
            lines: true,
            cascadeCheck: true
        });
    });


    function accredit() {
        var ids = '';
        var checkStates = '';

        var nodes = $('#tt').tree('getChecked', ['checked', 'indeterminate']);
        if (nodes.length < 1) {
            $.messager.alert("提示框", "请选择授权列表!", "warning");
            return;
        }

        $.each(nodes, function (i, v) {
            ids += v.id + ",";
            checkStates += v.checkState + ',';
        });

        var index = ids.indexOf(SYSTEM_CONST.SYSTEM_CONFIG_MENU_ID);
        if (index !== -1) {
            $.messager.confirm('确认框', '系统设置权限较大，请慎重选择！', function (r) {
                if (r) {
                    accreditRoles(ids, checkStates);
                }
            });
        } else {
            accreditRoles(ids, checkStates);
        }
    }


    function accreditRoles(ids, checkStates) {

        var url = contextRootPath + '/role/resourceTreeNodesSave';
        var params = {"ids": ids, "roleId": "#(role_id)", "checkStates": checkStates};

        $.post(url, params, function (data) {
            var params = {};
            params.element = _datagrid;
            params.data = data;
            resultCallback(params);
        });
    }


</script>

#end


